package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsBoxHole;
import com.milling.business.service.IWmsBoxHoleService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * 盒子孔位信息Controller
 *
 * @author X
 * @date 2025-09-12
 */
@RestController
@RequestMapping("/business/wmsBoxHole")
public class WmsBoxHoleController extends BaseController
{
    @Autowired
    private IWmsBoxHoleService wmsBoxHoleService;

    /**
     * 查询盒子孔位信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:wmsBoxHole:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsBoxHole wmsBoxHole)
    {
        startPage();
        List<WmsBoxHole> list = wmsBoxHoleService.selectWmsBoxHoleList(wmsBoxHole);
        return getDataTable(list);
    }

    /**
     * 导出盒子孔位信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:wmsBoxHole:export')")
    @Log(title = "盒子孔位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsBoxHole wmsBoxHole)
    {
        List<WmsBoxHole> list = wmsBoxHoleService.selectWmsBoxHoleList(wmsBoxHole);
        ExcelUtil<WmsBoxHole> util = new ExcelUtil<WmsBoxHole>(WmsBoxHole.class);
        util.exportExcel(response, list, "盒子孔位信息数据");
    }

    /**
     * 获取盒子孔位信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:wmsBoxHole:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsBoxHoleService.selectWmsBoxHoleById(id));
    }

    /**
     * 新增盒子孔位信息
     */
    @PreAuthorize("@ss.hasPermi('business:wmsBoxHole:add')")
    @Log(title = "盒子孔位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsBoxHole wmsBoxHole)
    {
        return toAjax(wmsBoxHoleService.insertWmsBoxHole(wmsBoxHole));
    }

    /**
     * 修改盒子孔位信息
     */
    @PreAuthorize("@ss.hasPermi('business:wmsBoxHole:edit')")
    @Log(title = "盒子孔位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsBoxHole wmsBoxHole)
    {
        return toAjax(wmsBoxHoleService.updateWmsBoxHole(wmsBoxHole));
    }

    /**
     * 删除盒子孔位信息
     */
    @PreAuthorize("@ss.hasPermi('business:wmsBoxHole:remove')")
    @Log(title = "盒子孔位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsBoxHoleService.deleteWmsBoxHoleByIds(ids));
    }
}
